import { Injectable } from '@angular/core';
import { EntityConfig } from '../../core/entity-config.types';
import { BillOfMaterialsDto } from '../../proxy/joy/erp/basic-archives/item-masters';
import { DatePipe } from '@angular/common';
import { LocalizationService } from '@abp/ng.core';

@Injectable({
  providedIn: 'root'
})
export class BillOfMaterialsConfigService {
  private datePipe = new DatePipe('zh-CN');

  constructor(private localization: LocalizationService) {}

  getConfig(): EntityConfig {
    return {
      entityType: 'Joy.Erp.BasicArchives.ItemMasters.BillOfMaterials',
      propertys: [
        {
          name: 'ItemCode',
          key: 'itemCode',
          type: 'string',
          field: (item: BillOfMaterialsDto) => item.itemCode,
          width: 200,
          show: true,
          order: 0,
          fixed: 0
        },
        {
          name: 'Version',
          key: 'version',
          type: 'string',
          field: (item: BillOfMaterialsDto) => item.version,
          width: 200,
          show: true,
          order: 0,
          fixed: 0
        },
        {
          name: 'DisplayName',
          key: 'displayName',
          type: 'string',
          field: (item: BillOfMaterialsDto) => item.displayName,
          width: 200,
          show: true,
          order: 0,
          fixed: 0
        },
        {
          name: 'ItemName',
          key: 'itemName',
          type: 'string',
          field: (item: BillOfMaterialsDto) => item.itemName,
          width: 200,
          show: true,
          order: 0,
          fixed: 0
        },
        {
          name: 'ItemSpec',
          key: 'itemSpec',
          type: 'string',
          field: (item: BillOfMaterialsDto) => item.itemSpec,
          width: 200,
          show: true,
          order: 0,
          fixed: 0
        },
        {
          name: 'UseCount',
          key: 'useCount',
          type: 'number',
          field: (item: BillOfMaterialsDto) => item.useCount,
          width: 200,
          show: true,
          order: 0,
          fixed: 0
        },
        {
          name: 'UnitId',
          key: 'unitId',
          type: 'number',
          field: (item: BillOfMaterialsDto) => item.unit.unit.displayName,
          width: 200,
          show: true,
          order: 0,
          fixed: 0
        }
      ]
    };
  }

  private l(key: string, ...params: string[]): string {
    return this.localization.instant(key, ...params);
  }
} 